package com.pactera.miyuangroup.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.pactera.miyuangroup.db.entity.VehicleUser;
import com.pactera.miyuangroup.db.mapper.VehicleUserMapper;
import com.pactera.miyuangroup.service.VehicleUserService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.pactera.miyuangroup.vo.request.PageRequest;
import com.pactera.miyuangroup.vo.request.web.PageDeliverymanAdjustReq;
import com.pactera.miyuangroup.vo.response.web.PageDeliverymanAdjustRecordRes;
import com.pactera.miyuangroup.vo.response.web.PageDeliverymanAdjustRes;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 车辆人员关系 服务实现类
 * </p>
 *
 * @author WangWu
 * @since 2018-04-13
 */
@Service
public class VehicleUserServiceImp extends ServiceImpl<VehicleUserMapper, VehicleUser> implements VehicleUserService {


    /**
     * 调整明细查询
     * @param id 车辆ID
     * @param req
     * @return
     */
    @Override
    public Page<PageDeliverymanAdjustRecordRes> selectListAdjustRecordPage(String id, PageRequest req) {

        Page<PageDeliverymanAdjustRecordRes> pageList = new Page<>(req.getCurrent(), req.getSize());
        EntityWrapper ew = new EntityWrapper();
        List<PageDeliverymanAdjustRecordRes> page = Collections.emptyList();
        if (StringUtils.isNotBlank(id)) {
            ew.eq("vehicle_id", id);
            page = baseMapper.selectListDeliverymanAdjustRecord(pageList, ew);
        }

        pageList.setRecords(page);
        return pageList;
    }
}
